<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
        width="600px"
      >
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          size="small"
          label-width="120px"
        >
          <el-form-item label="场景ID" prop="houseShowSceneId">
            <el-input v-model="form.houseShowSceneId" style="width: 370px" />
          </el-form-item>
          <el-form-item label="展示配置ID">
            <el-input v-model="form.houseShowConfigId" style="width: 370px" />
          </el-form-item>
          <el-form-item label="场景名称">
            <el-input v-model="form.text" style="width: 370px" />
          </el-form-item>
          <el-form-item label="场景缩略图">
            <el-input v-model="form.img" style="width: 370px" />
          </el-form-item>
          <el-form-item label="场景详情内容">
            <el-input v-model="form.detail" style="width: 370px" />
          </el-form-item>
          <el-form-item label="视野水平高度">
            <el-input v-model="form.hfov" style="width: 370px" />
          </el-form-item>
          <el-form-item
            label="X轴"
          >
            <el-input v-model="form.pitch" style="width: 370px" />
          </el-form-item>
          <el-form-item label="y轴">
            <el-input v-model="form.yaw" style="width: 370px" />
          </el-form-item>
          <el-form-item
            label="场景类型"  >
            <el-input v-model="form.type" style="width: 370px" />
          </el-form-item>
          <el-form-item label="单张全景图">
            <el-input v-model="form.panorama" style="width: 370px" />
          </el-form-item>
          <el-form-item
            label="cubemap图片"
          >
            <el-input v-model="form.cubeMap" style="width: 370px" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" style="width: 370px" />
          </el-form-item>
          <el-form-item label="创建时间">
            <el-input v-model="form.createTime" style="width: 370px" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button
            :loading="crud.status.cu === 2"
            type="primary"
            @click="crud.submitCU"
            >确认</el-button
          >
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        style="width: 100%"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column prop="houseShowSceneId" label="场景ID" />
        <el-table-column prop="houseShowConfigId" label="展示配置ID" />
        <el-table-column prop="text" label="场景名称" />
        <el-table-column prop="img" label="场景缩略图" />
        <el-table-column
          prop="detail"
          label="场景详情内容"
        />
        <el-table-column prop="hfov" label="视野水平高度" />
        <el-table-column
          prop="pitch"
          label="X轴旋转"
        />
        <el-table-column prop="yaw" label="y轴旋转" />
        <el-table-column
          prop="type"
          label="场景类型" />
        <el-table-column
          prop="panorama"
          label="单张全景图"
        />
        <el-table-column
          prop="cubeMap"
          label="cubemap图片"
        />
        <el-table-column prop="updateTime" label="更新时间" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column
          v-if="
            checkPer(['admin', 'houseShowScene:edit', 'houseShowScene:del'])
          "
          label="操作"
          width="150px"
          align="center"
        >
          <template slot-scope="scope">
            <udOperation :data="scope.row" :permission="permission" />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudHouseShowScene from "@/api/houseShow/houseShowScene";
import CRUD, { presenter, header, form, crud } from "@crud/crud";
import rrOperation from "@crud/RR.operation";
import crudOperation from "@crud/CRUD.operation";
import udOperation from "@crud/UD.operation";
import pagination from "@crud/Pagination";

const defaultForm = {
  houseShowSceneId: null,
  houseShowConfigId: null,
  text: null,
  img: null,
  detail: null,
  hfov: null,
  pitch: null,
  yaw: null,
  type: null,
  panorama: null,
  cubeMap: null,
  updateTime: null,
  createTime: null,
};
export default {
  name: "HouseShowScene",
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({
      title: "房屋场景",
      url: "api/houseShowScene",
      idField: "houseShowSceneId",
      sort: "houseShowSceneId,desc",
      crudMethod: { ...crudHouseShowScene },
    });
  },
  data() {
    return {
      permission: {
        add: ["admin", "houseShowScene:add"],
        edit: ["admin", "houseShowScene:edit"],
        del: ["admin", "houseShowScene:del"],
      },
      rules: {
        houseShowSceneId: [
          { required: true, message: "场景ID不能为空", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true;
    },
  },
};
</script>

<style scoped>
</style>
